package chapter4;

public class Child extends Base {
    private long sum;

    @Override
    public void add(int number) {
        System.out.println("child add");
        super.add(number);
        sum+=number;
    }

    @Override
    public void addAll(int[] numbers) {
        super.addAll(numbers);
        System.out.println("after super add all: sum=" + sum);
        for (int num : numbers) {
            sum+=num;
        }
        System.out.println("after child add all sum=" + sum);
    }

    public long getSum(){
        return sum;
    }


    public static void main(String[] args) {
        Child child = new Child();
        child.addAll(new int[]{1,2,3});
        System.out.println(child.getSum());
    }
}
